package com.peiwangroup.messageservice.model;

import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.OneToOne;
import jakarta.persistence.Table;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.PrePersist;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import lombok.NoArgsConstructor;
import lombok.AllArgsConstructor;

import java.math.BigDecimal;
import java.util.Date;
import java.util.UUID;

@Getter
@Setter
@ToString
@NoArgsConstructor
@AllArgsConstructor
@Entity
@Table(name = "wechat_messages")
public class WeChatMessage {
    @Id
    private String messageId;
    private String senderId;
    private String receiverId;
    private String content;
    private String messageType;
    private Date timestamp;
    
    @OneToOne
    @JoinColumn(name = "order_id")
    private Order order;
    
    private String orderType;
    private BigDecimal orderAmount;
    
    @PrePersist
    public void prePersist() {
        if (this.messageId == null) {
            this.messageId = UUID.randomUUID().toString();
        }
    }
}